var t = require("A4730AC3A71FB5DFC21562C4223CA4D1.js"), e = getApp(), o = 1, n = {
    _cb: null,
    login: function(t) {
        o += 20, setTimeout(function() {
            var e = getCurrentPages(), a = !1, i = !0, r = !1, u = void 0;
            try {
                for (var c, l = e[Symbol.iterator](); !(i = (c = l.next()).done); i = !0) if ("pages/register/auth" === c.value.route) {
                    a = !0;
                    break;
                }
            } catch (t) {
                r = !0, u = t;
            } finally {
                try {
                    !i && l.return && l.return();
                } finally {
                    if (r) throw u;
                }
            }
            a || (n._cb = t, wx.navigateTo({
                url: "/pages/register/auth"
            })), 101 === o && (o = 1);
        }, o);
    },
    thirdPartyLogin: function(o) {
        var a = n._cb;
        o.type = 4, t.post("/v2/authorization", o).then(function(t) {
            if (wx.hideLoading(), 200 === t.statusCode) if (1001 === t.data.code) {
                var o = t.data.response.data;
                if (0 === o.auth_type_login) wx.redirectTo({
                    url: "/pages/register/index?sessionId=" + o.session_id
                }); else {
                    try {
                        wx.setStorageSync("user", o);
                    } catch (t) {}
                    e.globalData.isLogin = !0, e.globalData.authToken = o.user_token, e.globalData.user = o, 
                    wx.navigateBack({
                        delta: 1,
                        complete: function() {
                            "function" == typeof a && (a(1001), n._cb = null);
                        }
                    });
                }
            } else setTimeout(function() {
                wx.redirectTo({
                    url: "/pages/register/auth"
                });
            }, 1500); else wx.navigateBack({
                delta: 1,
                complete: function() {
                    "function" == typeof a && (a(1005), n._cb = null);
                }
            });
        }).catch(function(t) {
            wx.hideLoading(), wx.navigateBack({
                delta: 1,
                complete: function() {
                    "function" == typeof a && (a(1005), n._cb = null);
                }
            });
        });
    },
    completeOrder: function(o, n) {
        wx.showLoading({
            mask: !0
        }), t.post("/v2/order/product/complete", {
            order_id: o
        }).then(function(t) {
            wx.hideLoading(), 1001 === t.data.code && (e.globalData.isEditOrder = !0, wx.showToast({
                title: t.data.msg
            }), "function" == typeof n && n());
        }).catch(function() {
            wx.hideLoading();
        });
    },
    getCouponCount: function(e, o) {
        t.get("/v2/coupon/available_quantity").then(function(t) {
            "function" == typeof e && e(t);
        }).then(function() {
            "function" == typeof o && o();
        });
    }
};

module.exports = n;